package com.qf.lanzhou.blog.api.dao.Impl;

import com.qf.lanzhou.blog.api.dao.DeleteArticleDao;
import com.qf.lanzhou.blog.api.pojo.entity.Article;
import com.qf.lanzhou.blog.api.util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @Author Nerly
 * @Date 2020/12/21 16:58
 * @JDK 1.8
 * @Version 1.0
 */
public class DeleteArticleDaoImpl implements DeleteArticleDao {
    private static QueryRunner queryRunner;

    static {
        queryRunner = new QueryRunner(DruidUtil.getDataSource());
    }

    @Override
    public void deleteArticle(Article article) {
        String sql = "DELETE FROM t_article WHERE article_id=?";
        try {
            queryRunner.update(sql, article.getArticleId());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
